Scheduled notifications sample


Windows Runtime, Windows 8.1, Windows Phone 8.1
User Interface, universal app
Windows RT
en-US
4/2/2014

This sample shows how to use scheduled and recurring tile updates and toast notifications for an app. This ability enables you to specify a precise time to deliver the notification, even if the app is not running.

Note  This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on both Windows 8.1 and Windows Phone 8.1. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see Build apps that target Windows and Windows Phone 8.1 by using Visual Studio.

The sample demonstrates the following scenarios:

  • Sending a scheduled tile or toast notification, that has optional repeat notifications at a certain interval
  • Querying for a tile or toast notification that is scheduled to display, and then removing the notification

For an app to send a toast notification, the developer must have declared that the app is toast-capable in its app manifest file (package.appxmanifest) as they have for this sample app. Normally, you do this using the Microsoft Visual Studio 2013 manifest editor, where you find the setting in the Application UI tab, under the Notifications section. For more info, see How to opt in for toast notifications.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Visual Studio 2013, go to Visual Studio 2013.

Related topics

Guidelines and checklist for scheduled notifications
How to schedule a tile notification
How to schedule a toast notification
Windows 8 Windows Store app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2
Phone
Windows Phone 8.1

Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

Deploying the sample

  • To deploy the built Windows version of the sample:

    1. Select ScheduledNotifications.Windows in Solution Explorer.
    2. Use Build > Deploy Solution or Build > Deploy ScheduledNotifications.Windows.
  • To deploy the built Windows Phone version of the sample:

    1. Select ScheduledNotifications.WindowsPhone in Solution Explorer.
    2. Use Build > Deploy Solution or Build > Deploy ScheduledNotifications.WindowsPhone.

Deploying and running the sample

  • To deploy and run the Windows version of the sample:

    1. Right-click ScheduledNotifications.Windows in Solution Explorer and select Set as StartUp Project.
    2. To debug the sample and then run it, press F5 or use Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
  • To deploy and run the Windows Phone version of the sample:

    1. Right-click ScheduledNotifications.WindowsPhone in Solution Explorer and select Set as StartUp Project.
    2. To debug the sample and then run it, press F5 or use Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
    3. Give it several seconds to launch in the emulator (it takes over the full screen, so if you're still seeing your Start screen tiles, the sample hasn't launched yet), after which you can find the sample in the Apps list. Add the tile's sample to the Start screen so that you can see the result of the action that you've taken in the sample. A tile must be pinned to the Start screen to receive notifications.

How to use the sample

After you schedule a tile or toast notification in the sample, switch to your Start screen to see the notification appear. Click the sample's tile to return to the sample.

When removing a notification in scenario 2, be sure to select the notification before you click Remove selected notifications from schedule.